Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextInput event is not raised on typing (#closes 1956) #2303

Merged
merged 5 commits into from
May 10, 2018

Conversation

AlexKamaev
Copy link
Contributor

No description provided.

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit b55ba99 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 2bc8b23 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 7308cd8 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 17b3c67 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit fe41fee have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 98b99a6 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 36d50a4 have failed. See details:

@AlexKamaev AlexKamaev force-pushed the gh-1956 branch 2 times, most recently from 9fb0806 to e35d579 Compare April 18, 2018 06:41
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit e35d579 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit f65dfc8 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 17814af have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit cfae5da have failed. See details:

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot \retest

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit cfae5da have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit d9ca271 have passed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit a246d72 have failed. See details:

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot \retest

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit a246d72 have failed. See details:

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot \retest

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit a246d72 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit a246d72 have passed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 4136a94 have passed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 0dff55c have failed. See details:

2 similar comments
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 0dff55c have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 0dff55c have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit abd0361 have failed. See details:

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot \retest

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit abd0361 have failed. See details:

3 similar comments
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit abd0361 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit abd0361 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit abd0361 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit b094470 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit b094470 have passed. See details:

@AlexKamaev
Copy link
Contributor Author

fpr @AndreyBelym @helen-dikareva

@@ -84,26 +105,68 @@ function _excludeInvisibleSymbolsFromSelection (selection) {
return selection;
}

// NOTE: Typing can be prevented in Chrome/Edge but can not be prevented in IE11 or Firefox
// Firefox does not support TextInput event
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we usually write comments this way

// NOTE: some text
// text without tab indent


let forceInputInSafari;

function simulateTextInput (element, text) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this method almost all textInput logic is written for Safari. May be it would be more clear if we e.g.:

function simulateTextInput (element, text) {
    //logic only for Safari
}

var beforeContentChanged = () => {
        if (browserUtils.isSafari)
            needProcessInput = simulateTextInput(element, text);
        else
            needProcessInput = browserUtils.isFirefox || eventSimulator.textInput(element, text) || browserUtils.isIE11;

        needRaiseInputEvent = needProcessInput && !browserUtils.isIE11;
};	

What do you think @AlexKamaev @AndreyBelym ?

Copy link
Contributor Author

@AlexKamaev AlexKamaev May 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use simulateTextInput not only in beforeContentChanged but also in _typeTextToTextEditable.
If we detach safari logic from eventSimulator.textInput(...) we will need to duplicate safari logic

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, ok then

// Safari supports the TextInput event but has a bug: e.data is added to the node value.
// So in Safari we need to call preventDefault in the last textInput handler but not prevent the Input event

let forceInputInSafari;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually I don't like nested methods, but in this case I would love to encapsulate logic for Safari in simulateTextInput method. We can move forceInputInSafari, onSafariTextInput, and onSafariPreventTextInput in it.
@AndreyBelym

@@ -439,6 +439,9 @@ $(document).ready(function () {
var fixedText = 'Test' + String.fromCharCode(160) + 'me' + String.fromCharCode(160) + 'all!';
var inputEventRaisedCount = 0;

// NOTE IE11 does not raise input event on contenteditable element
var expectedInputEventRaisedCount = !browserUtils.isIE11 ? 12 : 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's preferred to use strait condition where it's possible
var expectedInputEventRaisedCount = browserUtils.isIE11 ? 0 : 12;

it('Typing in the content editable element with "replace" option', function () {
return runTests('testcafe-fixtures/index.test.js', 'Type text in the content editable element');
return runTests('testcafe-fixtures/index.test.js', 'Type text in the content editable element', { skip: [ 'ie' ] });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. I can paste text in contenteditable by ctrl+v shortcut in IE. I think we should execute typeText action with replace option for IE. Do we?

Copy link
Contributor Author

@AlexKamaev AlexKamaev May 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test checks if input event happened. But in IE in contenteditable element input event never raised. So test is incorrect now for ie. We can dublicate this test for IE only without this additional check

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we skip only input event check for IE and leave check for typing itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

}

function isTargetElement(el, id) {
while (el) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can store required elements (such as const contentEditableWithModify = document.getElementById('contentEditableWithModify')) and use DOM element contains method

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 1827980 have passed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 7186e62 have failed. See details:

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot \retest

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 7186e62 have passed. See details:

@helen-dikareva helen-dikareva merged commit b3bb34c into DevExpress:master May 10, 2018
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this pull request Dec 18, 2019
* [WIP] process TextInput event on typing (closes DevExpress#1956)

* fix textInput dispatch in safari

* fix textInput dispatch in safari

* fix review remarks

* fix user agent module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants